home *** CD-ROM | disk | FTP | other *** search
/ Atari Mega Archive 1 / Atari Mega Archive - Volume 1.iso / mint / lib / mntlib44.zoo / mntlib / unlink.c < prev    next >
C/C++ Source or Header  |  1994-03-01  |  684b  |  42 lines

  1. /* unlink.c: by ERS. This routine is in the public domain */
  2.  
  3. #include <unistd.h>
  4. #include <limits.h>
  5. #include <stdlib.h>
  6. #include <errno.h>
  7. #include <osbind.h>
  8. #include <fcntl.h>
  9. #include "lib.h"
  10.  
  11. /* remove provided for ansi compatibility */
  12. #ifndef __GNUC__
  13. int remove(filename)
  14.     const char *filename;
  15. {
  16.     return unlink(filename);
  17. }
  18. #endif
  19.  
  20. #ifdef __GNUC__
  21. asm(".text; .even; .globl _remove; _remove:"); /* dept of dirty tricks */
  22. #endif
  23. int
  24. unlink(filename)
  25.     const char * filename;
  26. {
  27.     char name[PATH_MAX];
  28.     int r;
  29.  
  30.     _unx2dos(filename, name);
  31.  
  32.     r = (int)Fdelete(name);
  33.  
  34.     if (r < 0) {
  35.         if ((r == -EPATH) && (_enoent(name)))
  36.             r = -ENOENT;
  37.         errno = -r;
  38.         return -1;
  39.     }
  40.     return 0;
  41. }
  42.